<template>
<div class="wrapper">
  <swiper :options="swiperOption" v-if="list.length">
<!-- slides -->
    <swiper-slide v-for="item of list" :key="item.id">
      <img  class="swiper-img" :src="item.imgUrl" alt="">
    </swiper-slide>
  <!-- Optional controls -->
  <div class="swiper-pagination"  slot="pagination">
  </div>
  </swiper>
</div>
</template>

<script>
// loop：true指的是支持插件循环
export default {
  name: 'HomeSwiper',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true
      }
    }
  },
  computed: {
    showSwiper () {
      return this.list.length
    }
  }
}
</script>

<style lang="stylus" scoped>
// >>>是样式穿透，指的是swiper下面的子组件不受scoped限制
.wrapper >>> .swiper-pagination-bullet-active
  background: #fff
.wrapper
  height: 0
  width: 100%;
  overflow: hidden
  // 这里是说根据他的高度，会自动撑开31.25，实现了比例
  padding-bottom: 31.25%
  .swiper-pagination-bullet-active
    background:red !important
  .swiper-img
    width: 100%;
</style>
